﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Twodi.Implemented
{
    public abstract class Updateable : IUpdateable
    {
        protected bool enabled;

        protected int updateOrder;

        public Updateable()
        {

        }

        public abstract void Update(GameTime gameTime);

        public bool Enabled
        {
            get { return this.enabled; }
            set
            {
                this.enabled = value;
                onEnabledChanged(EventArgs.Empty);
            }
        }

        public int UpdateOrder
        {
            get { return this.updateOrder; }
            set
            {
                this.updateOrder = value;
                onUpdateOrderChanged(EventArgs.Empty);
            }
        }

        public event EventHandler<EventArgs> EnabledChanged; 

        public event EventHandler<EventArgs> UpdateOrderChanged;

        protected virtual void onEnabledChanged(EventArgs e)
        {
            if (EnabledChanged != null)
            {
                EnabledChanged(this, e);
            }
        }

        protected virtual void onUpdateOrderChanged(EventArgs e)
        {
            if (UpdateOrderChanged != null)
            {
                UpdateOrderChanged(this, e);
            }
        }
    }
}
